import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  BaseEntity,
  CreateDateColumn,
} from 'typeorm';
import { IsNotEmpty, IsString, Length } from 'class-validator';

@Entity()
export class Track extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({
    length: 20,
    unique: true,
  })
  @IsNotEmpty()
  @Length(6, 20, {
    message: '名称长度必须在6-20之间',
  })
  @IsString({ message: '名称必须是字符串' })
  name: string;

  @Column()
  fileUrl: string;

  @Column()
  modelUrl: string;

  @Column('json')
  mate: Record<string, any>;

  @CreateDateColumn()
  createdAt: Date;
}
